$(document)
		.ready(
				function() {
					// 供应商下拉框的数据绑定
					var retutnApplyVue = new Vue({
						el : '#returnApplyDiv',
						data : {
							items : null
						},
						methods : {
							confirm : function(item) {
								openShowBox(item);
							}
						},
						beforeCreate : function() {
							updateList();
						}
					});

					var returnApplyBox=null;
					// 打开查看采购申请窗口
					function openShowBox(item) {
						var url = 'returnApply/getReturnApplyByPrimaryKeyReturnTo?returnApplyId='
								+ item.returnApplyId
								+ '&remark='
								+ 'exame' + '&returnTo=showReturnApply';
						returnApplyBox=layer.open({
							type : 2,
							maxmin : true,
							title : '查看退货申请',
							offset : '4%',
							btnAlign : 'c',
							area : [ '70%', '92%' ],
							btn : [ '确认退货', '拒绝退货' ],
							shadeClose : true, // 点击遮罩关闭
							yes : function() {
								var childBox = layer.getChildFrame(
										'body', returnApplyBox);
								var exameSuggestion = childBox.find(
										"#inputExameSuggestion").val();
								
								var data={
									"returnApplyId":item.returnApplyId,
									"exameSuggestion":exameSuggestion,
									"state":2
								};
								
								sendConfirmAlert('确认退货？','returnApply/exameReturnApplyAjax',data);
							},
							btn2 : function() {
								var childBox = layer.getChildFrame(
										'body', returnApplyBox);
								var exameSuggestion = childBox.find(
										"#inputExameSuggestion").val();
								
								var data={
									"returnApplyId":item.returnApplyId,
									"exameSuggestion":exameSuggestion,
									"state":3
								};
									
									sendConfirmAlert('拒绝退货？','returnApply/exameReturnApplyAjax',data);
							},
							content : SERVER_PRE_URL + url
						});
						
						
						
						
				

					}
					
					function sendConfirmAlert(title,url,data){
						layer.confirm(title, {
							  btn: ['确定','取消'] //按钮
							}, function(){
								baseUtil.httpSend(url, data, showConfirmResult);
							}, function(){
								
							});
					}
					
					function showConfirmResult(result){
						if (result == 1) {
							layer.msg('操作成功!');
							layer.close(returnApplyBox);
							updateList();
						} else {
							layer.msg('操作失败!');
						}
					}

					//更新采购订单的列表
					function updateList() {
						$.get(SERVER_PRE_URL
								+ "returnApply/getReturnApplyByStateAndSupplierIdAjax?state=1",
								function(data) {
							retutnApplyVue.items = data;
								});
					}

				});